package com.niuniu.rushdorm.controller;

import com.niuniu.rushdorm.pojo.response.BuildingList;
import com.niuniu.rushdorm.pojo.response.EmptyCount;
import com.niuniu.rushdorm.pojo.response.Rows;
import com.niuniu.rushdorm.pojo.vo.ResultVO;
import com.niuniu.rushdorm.service.BedService;
import com.niuniu.rushdorm.service.BuildingSevice;
import com.niuniu.rushdorm.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author rambo
 * 2022/11/25
 */
@RestController
public class RoomController {
    @Autowired
    BuildingSevice buildingSevice;
    @Autowired
    RoomService roomService;
    @Autowired
    BedService bedService;
    @GetMapping("/room/buildinglist")
    public ResultVO GetBuildingList(){
        BuildingList bl = new BuildingList();
        bl.setRows(buildingSevice.GetBuildings());
        return ResultVO.success(bl);
    }
    @GetMapping("/room/building")
    public ResultVO GetBuildingById(@RequestParam("id") long id){
        return ResultVO.success(buildingSevice.GetBuildingById(id));
    }
    @GetMapping("/room/room")
    public ResultVO GetRoomById(@RequestParam("id") long id){
        return ResultVO.success(roomService.GetRoomById(id));
    }
    @GetMapping("/room/empty")
    public ResultVO GetEmptyBeds(){
        Rows<List<EmptyCount>> rows = new Rows<>();
        rows.setRow(bedService.GetEmpty());
        return ResultVO.success(rows);
    }
}
